package pl.zmudzinski.jdk.newsletter.publisher;

import com.google.inject.Inject;
import pl.zmudzinski.jdk.newsletter.provider.NewsletterProvider;

import java.util.Observable;

/**
 * @author lukasz.zmudzinski
 */
public class NewsletterPublisherImpl extends Observable implements NewsletterPublisher {

    private final NewsletterProvider provider;

    @Inject
    public NewsletterPublisherImpl(NewsletterProvider provider) {
        this.provider = provider;
    }

    public void publish() {
        System.out.println("NewsletterPublisherImpl#publishing newsletter");
        setChanged();
        notifyObservers(provider.get());
        clearChanged();
    }
}
